/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.casestudy1.view;

import com.casestudy1.main.MainMidlet;
import com.casestudy1.yuh.ReportTrafficInfoForm;
import com.sun.lwuit.Button;
import com.sun.lwuit.Command;
import com.sun.lwuit.Display;
import com.sun.lwuit.Label;
import com.sun.lwuit.animations.CommonTransitions;
import com.sun.lwuit.events.ActionEvent;
import com.sun.lwuit.events.ActionListener;
import com.sun.lwuit.layouts.BoxLayout;

/**
 *
 * @author Windsea
 */
public class MainMenuForm extends View {

    private Command cmLogout;
    private Command cmExit;

    public MainMenuForm(final MainMidlet midlet) {
        super(midlet);
        setTitle("Traffic Info");
//        Style titlestyle = new Style();
//        titlestyle.setAlignment(CENTER);
//        titlestyle.setBgPainter(new LinearGradientPainter(0, 0xffffff, false));
//        setTitleStyle(titlestyle);
//        getStyle().setBgPainter(new LinearGradientPainter(0xffffff, 0, false));
        setLayout(new BoxLayout(BoxLayout.Y_AXIS));
//        setTransitionInAnimator(CommonTransitions.createSlide(
//                CommonTransitions.SLIDE_HORIZONTAL, false, 1000));
        setTransitionOutAnimator(CommonTransitions.createSlide(
                CommonTransitions.SLIDE_HORIZONTAL, false, 1000));

        Button btn1 = new Button(" Blocked Traffic Point ", midlet.getImage("point"));
        btn1.getUnselectedStyle().setAlignment(Label.CENTER);
        btn1.getSelectedStyle().setAlignment(Label.CENTER);
        Button btn2 = new Button("Dao Duc Huy");
        Button btn3 = new Button("Tran Van Bang");
        Button btn4 = new Button("Tran Tien Dat");
        Button btn5 = new Button("Dinh Tuan Anh");
//        Button btn6 = new Button("Traffic sign");

        cmExit = new Command("Thoát") {
            public void actionPerformed(ActionEvent evt) {
                Display.getInstance().exitApplication();
            }
        };

        cmLogout = new Command("Đăng xuất") {
            public void actionPerformed(ActionEvent evt) {
                //remove user & password and return loginform
                midlet.getLoginForm().show();
            }
        };

        btn1.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                midlet.showBlockedTrafficForm();
            }
        });

        btn2.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                ReportTrafficInfoForm rtf = new ReportTrafficInfoForm(midlet);
                rtf.show();
            }
        });



        btn4.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                midlet.showMainForm();
            }
        });
        btn5.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                midlet.showSearchBus();
            }
        });
        
        //add component      

        addComponent(btn1);
        addComponent(btn2);
        addComponent(btn3);
        addComponent(btn4);
        addComponent(btn5);
        addCommand(cmExit);
        addCommand(cmLogout);


    }
}
